<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <%layout("/WEB-INF/view/common/inc/admin_head.html",{title:'登录',styles:'bootstrap,font-awesome,animate,style'}){}%>
</head>

<body class="gray-bg">

    <div class="middle-box text-center loginscreen  animated fadeInDown">
        <div>
            <div>
                <h1 class="logo-name" style="font-size: 80px;">${app_info_sub_name}</h1>
            </div>
            <h3>欢迎使用${app_info_name}</h3>
            <h4 id="error-tip"></h4>
            <form id="login-form" class="m-t">
                <div class="form-group">
                    <input type="text" name="ac" class="form-control" placeholder="用户名" required="">
                </div>
                <div class="form-group">
                    <input type="password" name="pwd" class="form-control" placeholder="密码" required="">
                </div>
                <button type="button" class="login-btn btn btn-primary block full-width m-b">登 录</button>

            </form>
        </div>
    </div>
    
    <%layout("/WEB-INF/view/common/inc/admin_js.html",{modules:'jquery,bootstrap,layer'}){}%>
	<script>
        var back_url = '${backUrl!""}';
        $(function(){
            $('.login-btn').on('click',function(){
                doLogin();
            });

            $(document).keyup(function(e){
                var curKey = e.which;
                if(curKey==13 && $("input[name='ac']").val() != '' && $("input[name='pwd']").val() != '' ){
                    doLogin();
                }
            });

            //用户登录
            function doLogin(){
                layer.load();
                $('#error-tip').html('<span class="label label-info">登录中...</span>');
                $.post('${ctxPath}/admin/login.html',$('#login-form').serialize(),function(data){
                    if( data.ok ){
                        $('#error-tip').html('<span class="label label-success">'+data.msg+'</span>');
                        if( back_url == '/' || back_url == '' ){
                            location.href = "${ctxPath}/admin/index.html";
                        }else{
                            location.href = back_url;
                        }
                    }else{
                        $('#error-tip').html('<span class="label label-warning">'+data.msg+'</span>');
                    }
                },'json');
                layer.closeAll('loading');
            }
        });
    </script>
</body>

</html>
